<style lang="less">
    .insuranceBusiness {

    }
</style>
<template>
    <Tabs type="card" :animated="false" @on-click="tabClick" v-model="insuranceType" class="insuranceBusiness">
        <TabPane name="insuranceClaim" label="保险理赔" :disabled="disabled" icon="ios-bookmark">
            <Form class="basic-info" ref="insuranceBusinessForm.claimForm" :model="insuranceBusinessForm.claimForm"
                  :label-width="120" inline :rules="claimFormValidate">
                <FormItem label="案件编号">
                    <Input type="text" v-model="insuranceBusinessForm.claimForm.caseNo" disabled/>
                </FormItem>
                <FormItem label="申请时间">
                    <DatePicker type="datetime" format="yyyy-MM-dd HH:mm:ss" style="width: 160px"
                                v-model="insuranceBusinessForm.claimForm.applyDate"
                                disabled/>
                </FormItem>
                <FormItem label="结束时间">
                    <DatePicker type="datetime" format="yyyy-MM-dd HH:mm:ss" style="width: 160px"
                                v-model="insuranceBusinessForm.claimForm.endDate"
                                disabled/>
                </FormItem>
                <FormItem label="创建人">
                    <Input type="text" v-model="insuranceBusinessForm.claimForm.applyBy" disabled/>
                </FormItem>
                <FormItem label="出险日期" prop="riskDate">
                    <DatePicker :disabled="readOnly" transfer type="date" :options="options" format="yyyy-MM-dd"
                                style="width: 160px"
                                v-model="insuranceBusinessForm.claimForm.riskDate"/>
                </FormItem>
                <FormItem label="报案号" prop="reportNum">
                    <Input :disabled="readOnly" required type="text"
                           v-model="insuranceBusinessForm.claimForm.reportNum"/>
                </FormItem>
                <FormItem label="车辆受损情况" prop="carLossState">
                    <Select :disabled="readOnly"
                            transfer
                            @on-change="changeCarLossState"
                            v-model="insuranceBusinessForm.claimForm.carLossState"
                            style="width:160px"
                            placeholder="车辆受损情况">
                        <Option v-for="item in dataDic.carLossState" :value="item.value" :label="item.title"
                                :key="item.value">{{ item.title }}
                        </Option>
                    </Select>
                </FormItem>
                <FormItem label="资产损失" prop="assetsLoss">
                    <RuiNumber type="currency" :disabled="readOnly"
                               @on-change="getAssetAmount"
                               style="width:160px"
                               v-model="insuranceBusinessForm.claimForm.assetsLoss"
                               :min="0"
                               :precision="2"
                    />
                </FormItem>
                <FormItem label="理赔金额" v-if="!this.Obj.roleType">
                    <Select :disabled="readOnly" transfer v-model="insuranceBusinessForm.claimForm.claimAmount"
                            style="width:160px" clearable
                            placeholder="资产损失">
                        <Option v-for="item in dataDic.claimAmount" :value="item.value" :label="item.title"
                                :key="item.value">{{ item.title }}
                        </Option>
                    </Select>
                </FormItem>
                <FormItem label="责任占比" v-if="!this.Obj.roleType">
                    <Select :disabled="readOnly" transfer v-model="insuranceBusinessForm.claimForm.dutyRation"
                            style="width:160px" clearable
                            placeholder="责任占比">
                        <Option v-for="item in dataDic.dutyRation" :value="item.value" :label="item.title"
                                :key="item.value">{{ item.title }}
                        </Option>
                    </Select>
                </FormItem>
                <FormItem label="理赔比率" v-if="!this.Obj.roleType">
                    <InputNumber disabled style="width:160px"
                                 :max="100.00"
                                 :precision="2"
                                 :formatter="value => `${value}%`"
                                 :parser="value => value.replace('%', '')"
                                 v-model="insuranceBusinessForm.claimForm.claimRatio"/>
                </FormItem>
                <FormItem label="借款人伤情" v-if="!this.Obj.roleType">
                    <Select :disabled="readOnly" transfer v-model="insuranceBusinessForm.claimForm.lenderHurt"
                            style="width:160px" clearable
                            placeholder="借款人伤情">
                        <Option v-for="item in dataDic.lenderHurt" :value="item.value" :label="item.title"
                                :key="item.value">{{ item.title }}
                        </Option>
                    </Select>
                </FormItem>
                <FormItem label="支付目标账户" prop="payTargetAccount" v-if="!this.Obj.roleType">
                    <Input :disabled="readOnly" type="text" v-model="insuranceBusinessForm.claimForm.payTargetAccount"/>
                </FormItem>
                <FormItem label="支付金额" v-if="!this.Obj.roleType">
                    <!--                    <Input :disabled="readOnly" type="text" v-model="insuranceBusinessForm.claimForm.paymentAmount"/>-->
                    <RuiNumber type="currency" :disabled="readOnly"
                               style="width:160px"
                               v-model="insuranceBusinessForm.claimForm.paymentAmount"
                               :min="0"
                               :precision="2"
                    />
                </FormItem>
                <FormItem label="赔偿款类型" :required="required" prop="reparationType" v-if="!this.Obj.roleType">
                    <Select :disabled="readOnly" transfer
                            @on-open-change="initGetCase('reparationType','insuranceClaim')"
                            v-model="insuranceBusinessForm.claimForm.reparationType" style="width:160px"
                            placeholder="赔偿款类型">
                        <Option :value="'全部'">{{ '全部' }}</Option>
                        <Option v-for="item in caseData.reparationType" :value="item.opinion" :label="item.opinion"
                                :key="item.opinion">{{ item.opinion }}
                        </Option>
                    </Select>
                    <Button type="primary" @click="caseTypeAdd('reparationType')">自定义</Button>
                </FormItem>
                <Row>
                    <FormItem label="风险意见" prop="riskOpinion"
                              v-if="!this.Obj.roleType&&this.Obj.editFlag&&this.Obj.processStatus!=='draft'&&this.Obj.currentAbsoluteOverdue>0">
                        <Select :disabled="readOnly||!this.Obj.isFX" transfer
                                @on-open-change="initGetCase('riskOpinion','insuranceClaim')"
                                v-model="insuranceBusinessForm.claimForm.riskOpinion" style="width:160px" clearable
                                placeholder="风险意见">
                            <Option v-for="item in caseData.riskOpinion" :value="item.opinion" :label="item.opinion"
                                    :key="item.opinion">{{ item.opinion }}
                            </Option>
                        </Select>
                        <Button type="primary" @click="caseTypeAdd('riskOpinion')">自定义</Button>
                    </FormItem>
                </Row>
                <Row>
                    <Col span="24">
                        <FormItem label="原因简述" style="width: 100%;"
                                  v-if="this.Obj.processStatus !== undefined && this.Obj.processStatus!=='draft' && this.Obj.processStatus!=='toBeRepaired'">
                            <textarea disabled type="textarea" style="width: 100%"
                                      v-model="insuranceBusinessForm.claimForm.remarks"/>
                        </FormItem>
                        <FormItem label="原因简述" v-else style="width: 100%;">
                            <textarea :disabled="readOnly" type="textarea" style="width: 100%"
                                      v-model="insuranceBusinessForm.claimForm.remarks"/>
                        </FormItem>
                    </Col>
                </Row>
                <Row>
                    <FormItem label="处理意见"
                              v-if="this.Obj.processStatus==='toBeRepaired'">
                        <textarea disabled type="textarea" style="width: 500px"
                                  v-model="insuranceBusinessForm.approvalOpinion"/>
                    </FormItem>
                </Row>
                <Row>
                    <FormItem label="申请资料:" required>
                        <Button type="primary" @click="openUploadModal('insuranceClaimImage',true)">申请资料</Button>
                    </FormItem>
                </Row>
                <Row>
                    <FormItem v-if="!this.Obj.roleType && isApprove" label="授权文件:">
                        <Button type="primary" @click="openUploadModal('insuranceClaimFile')">授权文件</Button>
                    </FormItem>
                </Row>
            </Form>
        </TabPane>
        <TabPane name="insuranceRenew" :disabled="disabled" label="保险续保" icon="ios-bookmark">
            <Form class="basic-info" ref="insuranceBusinessForm.renewForm" :model="insuranceBusinessForm.renewForm"
                  :label-width="120" inline :rules="renewFormValidate">
                <FormItem label="案件编号">
                    <Input type="text" v-model="insuranceBusinessForm.renewForm.caseNo" disabled/>
                </FormItem>
                <FormItem label="申请时间">
                    <DatePicker type="datetime" format="yyyy-MM-dd HH:mm:ss" style="width: 160px"
                                v-model="insuranceBusinessForm.renewForm.applyDate" disabled/>
                </FormItem>
                <FormItem label="结束时间">
                    <DatePicker type="datetime" format="yyyy-MM-dd HH:mm:ss" style="width: 160px"
                                v-model="insuranceBusinessForm.renewForm.endDate" disabled/>
                </FormItem>
                <FormItem label="创建人">
                    <Input type="text" v-model="insuranceBusinessForm.renewForm.applyBy" disabled/>
                </FormItem>
                <FormItem label="商业险保单号" prop="insureNumCom">
                    <Input :disabled="readOnly" type="text" v-model="insuranceBusinessForm.renewForm.insureNumCom"/>
                </FormItem>
                <FormItem label="商业险保险公司" prop="insureCompanyCom">
                    <Select :disabled="readOnly" transfer v-model="insuranceBusinessForm.renewForm.insureCompanyCom"
                            style="width:160px"
                            placeholder="商业险保险公司">
                        <Option v-for="item in dataDic.insureCompany" :value="item.value" :label="item.title"
                                :key="item.value">{{ item.title }}
                        </Option>
                    </Select>
                    <!--                    <Input :disabled="readOnly" type="text" v-model="insuranceBusinessForm.renewForm.insureCompanyCom"/>-->
                </FormItem>
                <FormItem label="商业险开始日期" prop="insuranceStartTimeCom">
                    <DatePicker :disabled="readOnly" type="date" transfer format="yyyy-MM-dd" style="width: 160px"
                                v-model="insuranceBusinessForm.renewForm.insuranceStartTimeCom"/>
                </FormItem>
                <FormItem label="商业险结束日期" prop="insuranceEndTimeCom">
                    <DatePicker :disabled="readOnly" transfer type="date" format="yyyy-MM-dd" style="width: 160px"
                                v-model="insuranceBusinessForm.renewForm.insuranceEndTimeCom"/>
                </FormItem>
                <FormItem label="交强险保单号">
                    <Input :disabled="readOnly" type="text" v-model="insuranceBusinessForm.renewForm.insureNumTph"/>
                </FormItem>
                <FormItem label="交强险保险公司">
                    <Select :disabled="readOnly" transfer v-model="insuranceBusinessForm.renewForm.insureCompanyTph"
                            style="width:160px"
                            placeholder="交强险保险公司">
                        <Option v-for="item in dataDic.insureCompany" :value="item.value" :label="item.title"
                                :key="item.value">{{ item.title }}
                        </Option>
                    </Select>
                    <!--                    <Input :disabled="readOnly" type="text" v-model="insuranceBusinessForm.renewForm.insureCompanyTph"/>-->
                </FormItem>
                <FormItem label="交强险开始日期">
                    <DatePicker :disabled="readOnly" transfer type="date" format="yyyy-MM-dd" style="width: 160px"
                                v-model="insuranceBusinessForm.renewForm.insuranceStartTimeTph"/>
                </FormItem>
                <FormItem label="交强险结束日期">
                    <DatePicker :disabled="readOnly" transfer type="date" format="yyyy-MM-dd" style="width: 160px"
                                v-model="insuranceBusinessForm.renewForm.insuranceEndTimeTph"/>
                </FormItem>
                <FormItem label="投保方式" prop="insureMode">
                    <Select :disabled="readOnly" transfer v-model="insuranceBusinessForm.renewForm.insureMode"
                            style="width:160px"
                            placeholder="投保方式">
                        <Option v-for="item in dataDic.insuranceMode" :value="item.value" :label="item.title"
                                :key="item.value">{{ item.title }}
                        </Option>
                    </Select>
                </FormItem>
                <Row>
                    <Col span="24">
                        <FormItem label="原因简述" style="width: 100%;"
                                  v-if="this.Obj.processStatus !== undefined && this.Obj.processStatus!=='draft' && this.Obj.processStatus!=='toBeRepaired'">
                                <textarea disabled type="textarea" style="width: 100%;"
                                          v-model="insuranceBusinessForm.renewForm.remarks"/>
                        </FormItem>
                        <FormItem label="原因简述" v-else style="width: 100%;">
                                <textarea :disabled="readOnly" type="textarea" style="width: 100%;"
                                          v-model="insuranceBusinessForm.renewForm.remarks"/>
                        </FormItem>
                    </Col>
                </Row>
                <Row>
                    <FormItem label="处理意见"
                              v-if="this.Obj.processStatus==='toBeRepaired'">
                        <textarea disabled type="textarea" style="width: 500px"
                                  v-model="insuranceBusinessForm.approvalOpinion"/>
                    </FormItem>
                </Row>
                <Row>
                    <FormItem label="申请资料:" required>
                        <Button type="primary" @click="openUploadModal('insuranceRenewImage',true)">申请资料</Button>
                    </FormItem>
                </Row>
            </Form>
        </TabPane>
        <TabPane name="insuranceChange" :disabled="disabled" label="保险批改" icon="ios-bookmark">
            <Form class="basic-info" ref="insuranceBusinessForm.changeForm" :model="insuranceBusinessForm.changeForm"
                  :label-width="120" inline :rules="changeFormValidate">
                <FormItem label="案件编号">
                    <Input type="text" v-model="insuranceBusinessForm.changeForm.caseNo" disabled/>
                </FormItem>
                <FormItem label="申请时间">
                    <DatePicker type="datetime" format="yyyy-MM-dd HH:mm:ss" style="width: 160px"
                                v-model="insuranceBusinessForm.changeForm.applyDate" disabled/>
                </FormItem>
                <FormItem label="结束时间">
                    <DatePicker type="datetime" format="yyyy-MM-dd HH:mm:ss" style="width: 160px"
                                v-model="insuranceBusinessForm.changeForm.endDate" disabled/>
                </FormItem>
                <FormItem label="创建人">
                    <Input type="text" v-model="insuranceBusinessForm.changeForm.applyBy" disabled/>
                </FormItem>
                <Row>
                    <Col :sm="24" :md="12" :xl="8">
                        <FormItem label="商业险保单号" prop="insureNumCom">
                            <Input :disabled="readOnly" type="text"
                                   v-model="insuranceBusinessForm.changeForm.insureNumCom"/>
                        </FormItem>
                    </Col>
                    <Col :sm="24" :md="12" :xl="8" v-if="!this.Obj.roleType">
                        <FormItem label="授权内容" prop="licensedContent">
                            <div style="display: flex;flex-flow: row;">
                                <Select :disabled="readOnly" transfer
                                        @on-open-change="initGetCase('licensedContent','insuranceChange')"
                                        v-model="insuranceBusinessForm.changeForm.licensedContent" style="width:160px"
                                        clearable
                                        placeholder="授权内容">
                                    <Option v-for="item in caseData.licensedContent" :value="item.opinion"
                                            :label="item.opinion"
                                            :key="item.opinion">{{ item.opinion }}
                                    </Option>
                                </Select>
                                <Button style="margin-left: 8px;" type="primary"
                                        @click="caseTypeAdd('licensedContent')">自定义
                                </Button>
                            </div>

                        </FormItem>
                    </Col>
                    <Col :sm="24" :md="12" :xl="8" v-if="!this.Obj.roleType">
                        <FormItem label="批改原因" prop="reasonCorrection">
                            <div style="display: flex;flex-flow: row;">
                                <Select :disabled="readOnly" transfer
                                        @on-open-change="initGetCase('reasonCorrection','insuranceChange')"
                                        v-model="insuranceBusinessForm.changeForm.reasonCorrection" style="width:160px"
                                        clearable
                                        placeholder="批改原因">
                                    <Option v-for="item in caseData.reasonCorrection" :value="item.opinion"
                                            :label="item.opinion"
                                            :key="item.opinion">{{ item.opinion }}
                                    </Option>
                                </Select>
                                <Button style="margin-left: 8px;" type="primary"
                                        @click="caseTypeAdd('reasonCorrection')">自定义
                                </Button>
                            </div>
                        </FormItem>
                    </Col>
                </Row>
                <Row>
                    <Col span="24">
                        <FormItem label="原因简述" style="width: 100%;"
                                  v-if="this.Obj.processStatus !== undefined && this.Obj.processStatus!=='draft' && this.Obj.processStatus!=='toBeRepaired'">
                                <textarea disabled type="textarea" style="width: 100%;"
                                          v-model="insuranceBusinessForm.changeForm.remarks"/>
                        </FormItem>
                        <FormItem label="原因简述" v-else style="width: 100%;">
                                <textarea :disabled="readOnly" type="textarea" style="width: 100%;"
                                          v-model="insuranceBusinessForm.changeForm.remarks"/>
                        </FormItem>
                    </Col>
                </Row>
                <Row>
                    <FormItem label="处理意见"
                              v-if="this.Obj.processStatus==='toBeRepaired'">
                        <textarea disabled type="textarea" style="width: 500px"
                                  v-model="insuranceBusinessForm.approvalOpinion"/>
                    </FormItem>
                </Row>
                <Row>
                    <FormItem label="申请资料:" required>
                        <Button type="primary" @click="openUploadModal('insuranceChangeImage',true)">申请资料</Button>
                    </FormItem>
                </Row>
                <Row>
                    <FormItem v-if="!this.Obj.roleType && isApprove" label="授权文件:">
                        <Button type="primary" @click="openUploadModal('insuranceChangeFile')">授权文件</Button>
                    </FormItem>
                </Row>
            </Form>
        </TabPane>
        <TabPane name="insuranceExit" :disabled="disabled" label="保险退保" icon="ios-bookmark">
            <Form class="basic-info" ref="insuranceBusinessForm.exitForm" :model="insuranceBusinessForm.exitForm"
                  :label-width="120" inline :rules="exitFormValidate">
                <FormItem label="案件编号">
                    <Input type="text" v-model="insuranceBusinessForm.exitForm.caseNo" disabled/>
                </FormItem>
                <FormItem label="申请时间">
                    <DatePicker type="datetime" format="yyyy-MM-dd HH:mm:ss" style="width: 160px"
                                v-model="insuranceBusinessForm.exitForm.applyDate" disabled/>
                </FormItem>
                <FormItem label="结束时间">
                    <DatePicker type="datetime" format="yyyy-MM-dd HH:mm:ss" style="width: 160px"
                                v-model="insuranceBusinessForm.exitForm.endDate" disabled/>
                </FormItem>
                <FormItem label="创建人">
                    <Input type="text" v-model="insuranceBusinessForm.exitForm.applyBy" disabled/>
                </FormItem>
                <FormItem label="商业险保单号" prop="insureNumCom">
                    <Input :disabled="readOnly" type="text" v-model="insuranceBusinessForm.exitForm.insureNumCom"/>
                </FormItem>
                <FormItem label="退保原因" prop="reasonsSurrender" v-if="!this.Obj.roleType">
                    <Select :disabled="readOnly" transfer
                            @on-open-change="initGetCase('reasonsSurrender','insuranceExit')"
                            v-model="insuranceBusinessForm.exitForm.reasonsSurrender" style="width:160px" clearable
                            placeholder="退保原因">
                        <Option v-for="item in caseData.reasonsSurrender" :value="item.opinion" :label="item.opinion"
                                :key="item.opinion">{{ item.opinion }}
                        </Option>
                    </Select>
                    <Button type="primary" @click="caseTypeAdd('reasonsSurrender')">自定义</Button>
                </FormItem>
                <Row>
                    <Col span="24">
                        <FormItem label="原因简述" style="width: 100%;"
                                  v-if="this.Obj.processStatus !== undefined && this.Obj.processStatus!=='draft' && this.Obj.processStatus!=='toBeRepaired'">
                                <textarea disabled type="textarea" style="width: 100%;"
                                          v-model="insuranceBusinessForm.exitForm.remarks"/>
                        </FormItem>
                        <FormItem label="原因简述" v-else style="width: 100%;">
                                <textarea type="textarea" style="width: 100%;"
                                          v-model="insuranceBusinessForm.exitForm.remarks" :disabled="readOnly"/>
                        </FormItem>
                    </Col>
                </Row>
                <Row>
                    <FormItem label="处理意见"
                              v-if="this.Obj.processStatus==='toBeRepaired'">
                        <textarea disabled type="textarea" style="width: 500px"
                                  v-model="insuranceBusinessForm.approvalOpinion"/>
                    </FormItem>
                </Row>
                <Row>
                    <FormItem label="申请资料:" required>
                        <Button type="primary" @click="openUploadModal('insuranceExitImageImage',true)">申请资料</Button>
                    </FormItem>
                </Row>
                <Row>
                    <FormItem v-if="!this.Obj.roleType && isApprove" label="授权文件:">
                        <Button type="primary" @click="openUploadModal('insuranceExitImageFile')">授权文件</Button>
                    </FormItem>
                </Row>
            </Form>
        </TabPane>
        <div>
            <Modal @on-visible-change="cancels" v-model="insuranceBusiness" :title="caseTitle" :width="900"
                   :closable="false" :mask-closable="false">
                <div v-if="caseTypeList">
                    <custInfo ref="custInfo" :customTitle="customTitle" :Obj="caseType"/>
                </div>
            </Modal>
            <UploadFileModal ref="uploadFileModal" :modal="isUploadFileModalOpen" @closeModal="closeModal"
                             :param="fileParams" :isPreview="isReadOnly"/>

        </div>
    </Tabs>
</template>
<script>
    import {getByTypes} from "_p/basic/api/admin/datadic";
    import {getCase} from "_p/basic/api/contract/common/case-type/case-type";
    import custInfo from "../common/case-type/case-type";
    import {
        getApprovalOpinion,
        getInsuranceData,
        financialAgreeByCar
    } from "_p/basic/api/contract/insurance/insuranceManage";
    import {mapGetters} from "vuex";
    import {roleType} from "@/projects/basic/api/contract/channel-type/channel-type";
    import UploadFileModal from "_p/basic/pages/contract/common/uploadFileModal/uploadFileModal"
    import {divided, multiply, verifyErrorToView} from "_p/basic/assets/contract/js/utils";

    export default {
        components: {
            custInfo,
            UploadFileModal
        },
        props: {
            Obj: {
                type: Object
            },
            readOnly: {
                type: Boolean,
                require: true
            },
            isApprove: {
                type: Boolean,
                require: true
            },
        },
        computed: {
            ...mapGetters({
                userInfo: "userInfo",
                roleType: "roles",
            }),
            // 是否是风险
            isRisk: function () {
                return roleType(this.roleType)
                // return true;
            },
        },
        data() {
            return {
                contractAmt: null,
                isReadOnly: null,
                isUploadFileModalOpen: false,
                fileParams: {},
                options: {
                    disabledDate(date) {
                        return date && date.valueOf() > Date.now();
                    }
                },
                customTitle: null,
                dataDic: {},
                insuranceBusiness: false,
                caseTypeList: false,
                required: false,
                dicKeys: [
                    "carLossState", "claimAmount", "dutyRation", "lenderHurt", "trackingCompany",
                    "insuranceMode", "insureCompany"
                ],
                caseData: {
                    riskOpinion: [],
                    reparationType: [],
                    licensedContent: [],
                    reasonCorrection: [],
                    reasonsSurrender: []

                },
                insuranceType: '',
                disabled: false,
                caseTitle: "自定义添加",
                insuranceBusinessForm: {
                    approvalOpinion: "",
                    type: "",
                    claimForm: {
                        claimRatio: null,
                        payTargetAccount: null,
                        reparationType: "全部"
                    },
                    renewForm: {},
                    exitForm: {},
                    changeForm: {}
                },
                claimFormValidate: {
                    carLossState: [
                        {required: true, message: "请选择车辆受损情况", trigger: "change"}
                    ],
                    riskDate: [
                        {required: true, type: 'date', message: "请输入出险日期", trigger: "change"}
                    ],
                    reportNum: [
                        {required: true, message: "请输入报案号", trigger: "blur"},
                        {type: 'string', min: 5, message: '报案号至少5位', trigger: 'blur'}
                    ],
                    riskOpinion: [
                        {required: true, message: "请选择风险意见", trigger: "change"}
                    ],
                    assetsLoss: [
                        {required: true, type: 'number', message: "请输入资产损失", trigger: 'blur'},
                    ],
                    payTargetAccount: [
                        {required: true, message: "请输入支付目标账户", trigger: "blur"}
                    ]
                },
                renewFormValidate: {
                    insureNumCom: [{required: true, message: "请输入商业险保单号", trigger: "blur"}],
                    insuranceEndTimeCom: [{required: true, type: 'date', message: "请选择商业险结束日期", trigger: "change"}],
                    insuranceStartTimeCom: [{required: true, type: 'date', message: "请选择商业险开始日期", trigger: "change"}],
                    insureCompanyCom: [{required: true, message: "请输入商业险保险公司", trigger: "blur"}],
                    insureMode: [{required: true, message: "请选择投保方式", trigger: "change"}],
                },
                changeFormValidate: {
                    licensedContent: [
                        {required: true, message: "请选择授权内容", trigger: "change"}
                    ],
                    reasonCorrection: [
                        {required: true, message: "请选择批改原因", trigger: "change"}
                    ],
                    insureNumCom: [
                        {required: true, message: "请输入商业险保单号", trigger: "blur"}
                    ]
                },
                exitFormValidate: {
                    reasonsSurrender: [
                        {required: true, message: "请选择退保原因", trigger: "change"}
                    ],
                    insureNumCom: [
                        {required: true, message: "请输入商业险保单号", trigger: "blur"}
                    ]
                }
            };
        },
        mounted() {
            if (!this.Obj.roleType) {
                this.initGetCase('riskOpinion', 'insuranceClaim');
                this.initGetCase('reparationType', 'insuranceClaim');
                this.initGetCase('licensedContent', 'insuranceChange');
                this.initGetCase('reasonCorrection', 'insuranceChange');
                this.initGetCase('reasonsSurrender', 'insuranceExit');
            }
            if (this.Obj.editFlag) {
                this.getInsurance();
            } else {
                this.insuranceType = this.Obj.type;
                this.insuranceBusinessForm.type = this.Obj.type;
            }
            this.initDataDic();
            if (this.Obj.editFlag) {
                this.disabled = true;
            }
            if (this.Obj.processStatus === 'toBeRepaired') {
                this.getApprovalOpinion();
            }
            this.financialAgreeByCar();
        },
        methods: {
            initDataDic() {
                let self = this;
                getByTypes(this.dicKeys).then(res => {
                    if (res.code === "0000" && res.data) {
                        self.dataDic = res.data;
                    }
                });
            },
            financialAgreeByCar() {
                financialAgreeByCar(this.Obj.contractNo).then(res => {
                    if (res.code === "0000") {
                        this.contractAmt = res.data.contractAmt;
                    }
                });
            },
            getAssetAmount() {
                //assetsLoss 输入值  // contractAmt 合同金额
                let assetsLoss = this.insuranceBusinessForm.claimForm.assetsLoss;
                let contractAmt = this.contractAmt;

                if (assetsLoss > contractAmt) {
                    this.insuranceBusinessForm.claimForm.claimRatio = 0;
                    this.insuranceBusinessForm.claimForm.assetsLoss = 0;
                    this.$Modal.error({
                        title: '金额不能大于合同金额(￥ ' + contractAmt + ')!',
                    });
                } else {
                    this.insuranceBusinessForm.claimForm.claimRatio = multiply(divided(assetsLoss, contractAmt), 100);
                }
            },
            changeCarLossState() {
                if (this.insuranceBusinessForm.claimForm.carLossState === 'totalLoss' ||
                    this.insuranceBusinessForm.claimForm.carLossState === 'stolen' ||
                    this.insuranceBusinessForm.claimForm.carLossState === 'robbed') {
                    this.insuranceBusinessForm.claimForm.payTargetAccount = '天津长城滨银汽车金融有限公司';
                    this.required = false;
                } else {
                    this.insuranceBusinessForm.claimForm.payTargetAccount = this.Obj.custName;
                    this.required = true;
                }
                this.$refs['insuranceBusinessForm.claimForm'].validateField('payTargetAccount');
            },
            getInsurance() {
                getInsuranceData(this.Obj.caseNo, this.Obj.request).then(res => {
                    this.insuranceType = res.data.type;
                    this.insuranceBusinessForm.type = res.data.type;
                    if (res.code === "0000" && res.data) {
                        if (res.data.type === 'insuranceClaim') {
                            this.insuranceBusinessForm.claimForm = res.data;
                            if (res.data.carLossState == 'nonTotalLoss') {
                                this.required = true;
                            } else {
                                this.required = false;
                            }
                        } else if (res.data.type === 'insuranceRenew') {
                            let json = JSON.parse(res.data.insureType);
                            this.insuranceBusinessForm.renewForm = json;
                            this.insuranceBusinessForm.renewForm.caseNo = res.data.caseNo;
                            this.insuranceBusinessForm.renewForm.applyDate = res.data.applyDate;
                            this.insuranceBusinessForm.renewForm.applyBy = res.data.applyBy;
                        } else if (res.data.type === 'insuranceChange') {
                            this.insuranceBusinessForm.changeForm = res.data;
                        } else if (res.data.type === 'insuranceExit') {
                            this.insuranceBusinessForm.exitForm = res.data;
                        }
                    }
                });
            },
            tabClick(name) {
                this.insuranceBusinessForm.type = name;
            },
            getApprovalOpinion() {
                getApprovalOpinion(this.Obj.contractNo, this.Obj.caseNo, this.Obj.request).then(res => {
                    if (res.code === "0000" && res.data) {
                        this.insuranceBusinessForm.approvalOpinion = res.data.approvalOpinion;
                    }
                })
            },
            //子组件校验，传递到父组件
            validateForm() {
                let flag = false;
                if (this.insuranceType === 'insuranceClaim') {
                    this.$refs['insuranceBusinessForm.claimForm'].validate(valid => {
                        flag = valid;
                        if (!flag) {
                            console.log(this.$refs['insuranceBusinessForm.claimForm']);
                            verifyErrorToView(this.$refs['insuranceBusinessForm.claimForm'].fields);
                        }
                    });
                }
                if (this.insuranceType === 'insuranceRenew') {
                    this.$refs['insuranceBusinessForm.renewForm'].validate(valid => {
                        flag = valid;
                        if (!flag) {
                            console.log(this.$refs['insuranceBusinessForm.renewForm']);
                            verifyErrorToView(this.$refs['insuranceBusinessForm.renewForm'].fields);
                        }
                    });
                    // flag = true;
                }
                if (this.insuranceType === 'insuranceChange') {
                    this.$refs['insuranceBusinessForm.changeForm'].validate(valid => {
                        flag = valid;
                        if (!flag) {
                            verifyErrorToView(this.$refs['insuranceBusinessForm.changeForm'].fields);
                        }
                    });
                }
                if (this.insuranceType === 'insuranceExit') {
                    this.$refs['insuranceBusinessForm.exitForm'].validate(valid => {
                        flag = valid;
                        if (!flag) {
                            verifyErrorToView(this.$refs['insuranceBusinessForm.exitForm'].fields);
                        }
                    });
                }
                return flag
            },
            initGetCase(type, contractBusiness) {
                let self = this;
                getCase(type, contractBusiness).then(res => {
                    if (res.code === "0000" && res.data) {
                        self.caseData[type] = res.data;
                        console.log(type, res.data)
                    }
                });
            },
            cancels(bool) {
                this.caseTypeList = bool;
            },
            caseTypeAdd(type) {
                if (type === 'reparationType') {
                    this.customTitle = "赔偿款类型";
                } else if (type === 'riskOpinion') {
                    this.customTitle = "风险意见";
                } else if (type === 'licensedContent') {
                    this.customTitle = "授权内容";
                } else if (type === 'reasonCorrection') {
                    this.customTitle = "批改原因";
                } else if (type === 'reasonsSurrender') {
                    this.customTitle = "退保原因";
                }
                this.insuranceBusiness = true;
                this.caseTypeList = true;
                this.caseType = {
                    caseType: type,
                    contractBusiness: this.insuranceType
                }
            },
            closeModal() {
                let l = this.$refs.uploadFileModal.getFileList()
                console.log('申请资料 文件长度为：', l);

                this.isUploadFileModalOpen = false;
            },
            openUpload(params) {
                this.disabled = true;
                this.Obj.caseNo = params.caseNo
            },
            openUploadModal(type, file) {
                if (this.Obj.caseNo) {
                    this.fileParams = {
                        belongNo: this.Obj.contractNo,
                        busiNo: this.Obj.caseNo || type,
                        busiType: type,
                        busiData: {},
                        busiNodes: type //业务节点
                    };
                } else {
                    this.$Modal.warning({
                        title: "警告",
                        content: "请先保存业务数据！"
                    });
                    return;
                }
                if (file) {
                    this.isReadOnly = this.isApprove || this.readOnly;
                } else {
                    this.isReadOnly = false
                }
                this.isUploadFileModalOpen = true;
            },
        }
    };
</script>
